/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow-x: hidden;
}

/* Main container - responsive height */
#main-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Detect if in new tab/window */
@media (min-height: 600px) {
    #main-container {
        height: 90vh;
    }
}

/* Header tooltip */
#header-tooltip {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
    max-width: 90%;
    text-align: center;
}

#main-container:hover #header-tooltip {
    opacity: 1;
}

/* Interactive panel layout */
#interactive-panel {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr;
    gap: 15px;
    padding: 15px;
    min-height: 0;
}

/* Circle container */
#circle-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

#unit-circle {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
}

#angle-display {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-weight: bold;
    font-size: 14px;
}

/* Controls panel */
#controls-panel {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: #555;
    font-size: 13px;
}

/* Slider styling */
#angle-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

#angle-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

#angle-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

#angle-text {
    font-weight: bold;
    color: #667eea;
    text-align: center;
    font-size: 14px;
}

/* Button groups */
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.angle-btn {
    flex: 1;
    min-width: 44px;
    height: 32px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.angle-btn:hover, .angle-btn:focus {
    background: #667eea;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.angle-btn:active {
    transform: translateY(0);
}

/* Checkbox styling */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    cursor: pointer;
    min-height: 24px;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Primary button */
.primary-btn {
    width: 100%;
    height: 44px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.primary-btn:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.primary-btn:active {
    transform: translateY(0);
}

/* Values panel */
#values-panel {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#values-panel h3 {
    color: #555;
    font-size: 16px;
    margin-bottom: 5px;
    text-align: center;
}

.value-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 4px solid #667eea;
}

.value-label {
    font-weight: 600;
    color: #555;
    font-size: 14px;
}

.value-number {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #667eea;
    font-size: 14px;
    min-width: 60px;
    text-align: right;
}

.coordinate-display {
    background: #e3f2fd;
    padding: 10px;
    border-radius: 4px;
    text-align: center;
    font-size: 14px;
    margin-top: 5px;
}

.coord-label {
    color: #555;
    font-weight: 500;
}

.coord-value {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #1976d2;
}

/* Analytics panel */
#analytics-panel {
    background: white;
    border-top: 2px solid #eee;
    transition: all 0.3s ease;
    max-height: 200px;
}

#analytics-panel.collapsed {
    max-height: 45px;
}

#analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #f8f9fa;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

#analytics-header h3 {
    font-size: 14px;
    color: #555;
    margin: 0;
}

#toggle-analytics {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.3s;
}

#analytics-panel:not(.collapsed) #toggle-analytics {
    transform: rotate(180deg);
}

#analytics-content {
    padding: 10px 15px;
    max-height: 150px;
    overflow: hidden;
}

#analytics-panel.collapsed #analytics-content {
    display: none;
}

#analytics-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

#clear-log {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    min-height: 32px;
}

#session-time {
    font-size: 11px;
    color: #666;
    font-weight: 500;
}

#action-log {
    max-height: 100px;
    overflow-y: auto;
    font-size: 11px;
    line-height: 1.4;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #eee;
}

.log-entry {
    margin-bottom: 4px;
    padding: 2px 0;
    border-bottom: 1px solid #eee;
}

.log-time {
    color: #666;
    font-weight: 500;
}

.log-action {
    color: #333;
    margin-left: 5px;
}

/* Tooltips */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    max-width: 200px;
    word-wrap: break-word;
}

.tooltip.hidden {
    display: none;
}

/* Mobile responsive design */
@media (max-width: 768px) {
    #interactive-panel {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 10px;
        padding: 10px;
    }
    
    #circle-container {
        order: 1;
        min-height: 200px;
    }
    
    #controls-panel {
        order: 2;
        padding: 10px;
    }
    
    #values-panel {
        order: 3;
        padding: 10px;
    }
    
    .button-group {
        gap: 3px;
    }
    
    .angle-btn {
        min-width: 40px;
        height: 36px;
        font-size: 10px;
    }
    
    #analytics-panel {
        max-height: 150px;
    }
    
    #analytics-panel.collapsed {
        max-height: 40px;
    }
}

@media (max-width: 480px) {
    #main-container {
        border-radius: 0;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .angle-btn {
        width: 100%;
        min-width: auto;
    }
    
    #values-panel h3 {
        font-size: 14px;
    }
    
    .value-row {
        padding: 6px 8px;
    }
    
    .value-label, .value-number {
        font-size: 12px;
    }
}